home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
util
/
cdity
/
ModeProSrc.lha
/
Daemon
/
MPNodes.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-10-13
|
4KB
|
176 lines
#include "MP.h"
/*
mprefs will hold a shared lock on ListSem,
mpatch will obatin a shared lock
RemDNode & AddDNode must get a normal lock
*/
extern struct MPSem *MPSem;
void RemDNode(struct DefaultNode *DN)
{
if(DN)
{
Forbid();
SendPrefsMsg(MP_LISTSTATUS, MPLS_UPDATING, 0);
ObtainSemaphore(&MPSem->ListSem); // maybe shared with prefs
ObtainSemaphore(&MPSem->NodeSem);
Remove((struct Node *)DN);
ReleaseSemaphore(&MPSem->NodeSem);
ReleaseSemaphore(&MPSem->ListSem);
Permit();
SendPrefsMsg(MP_LISTSTATUS, MPLS_NORMAL, 0);
SendPrefsMsg(MP_REMNODE,0,DN);
FreeDNode(DN);
}
}
void AddDNode(ULONG dest, struct DefaultNode *n)
{
if(dest < 4 && n)
{
Forbid();
SendPrefsMsg(MP_LISTSTATUS, MPLS_UPDATING, 0);
ObtainSemaphoreShared(&MPSem->ListSem); // maybe shared with prefs
ObtainSemaphore(&MPSem->NodeSem);
AddHead(&MPSem->PromotionList[dest],(struct Node *)n);
n->Depth=max(1,n->Depth);
ReleaseSemaphore(&MPSem->NodeSem);
ReleaseSemaphore(&MPSem->ListSem);
Permit();
MPSem->LVActive=0;
MPSem->CurrentList=dest;
SendPrefsMsg(MP_LISTSTATUS, MPLS_NORMAL, 0);
SendPrefsMsg(MP_NEWNODE,dest,n);
SendPrefsMsg(MP_SAVE,0,0);
}
else
FreeDNode(n);
}
struct DefaultNode *FindDNode(struct List *list,UBYTE *name)
{
struct DefaultNode *dn;
UWORD l;
UBYTE str[128],patsrc[128];
UBYTE pat[258];
if(IsListEmpty(list))
{
return(NULL);
}
l=0;
if(name) // 4.55 @1
{
for(l=0;l<127 && name[l];l++)
{
str[l]=ToUpper(name[l]);
}
}
str[l]=0;
dn=(struct DefaultNode *)list->lh_Head;
while(dn && dn->Def_Node.ln_Succ!=0)
{
for(l=0;l<127 && dn->Def_Node.ln_Name[l];l++)
patsrc[l]=ToUpper(dn->Def_Node.ln_Name[l]);
patsrc[l]=0;
ParsePatternNoCase(patsrc,pat,258);
if(MatchPatternNoCase(pat,name))
return(dn);
dn=(struct DefaultNode *)dn->Def_Node.ln_Succ;
}
return(NULL);
}
struct DefaultNode *Find_SMNode(struct List *list, STRPTR name, ULONG ModeID)
{
struct DefaultNode *dn;
UWORD l,l2;
UBYTE str[128],patsrc[128];
UBYTE pat[258];
if(IsListEmpty(list))
{
return(NULL);
}
l=0;
if(name)
{
for(l=0;l<127 && name[l];l++)
str[l]=ToUpper(name[l]);
}
str[l]=0;
dn=(struct DefaultNode *)list->lh_Head;
while(dn && dn->Def_Node.ln_Succ!=0)
{
if(ModeID!=INVALID_ID)// (4.56.8)
{
if((dn->OrigDisplayID == ModeID) || (dn->OrigDisplayID == (ModeID | ALL_MODES)) )
{
return(dn);
}
}
l=l2=0;
while(l2<126 && dn->Def_Node.ln_Name[l])
{
if(dn->Def_Node.ln_Name[l]==' ')
{
patsrc[l2]='#';
l2++;
}
patsrc[l2]=ToUpper(dn->Def_Node.ln_Name[l]);
l++;
l2++;
}
patsrc[l2]=0;
ParsePatternNoCase(patsrc,pat,258);
if(MatchPatternNoCase(pat,name))
return(dn);
dn=(struct DefaultNode *)dn->Def_Node.ln_Succ;
}
return(NULL);
}
/*
BOOL MatchString(STRPTR Pattern, STRPTR String)
{
struct DefaultNode *dn;
UWORD l;
UBYTE str[128],patsrc[128];
UBYTE pat[258];
for(l=0;l<127 && String[l];l++)
str[l]=ToUpper(String[l]);
str[l]=0;
for(l=0;l<127 && Pattern[l];l++)
patsrc[l]=ToUpper(Pattern[l]);
patsrc[l]=0;
ParsePatternNoCase(patsrc,pat,258);
return(MatchPatternNoCase(pat,String));
}
*/